Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix yamux close #309

Merged
merged 5 commits into from
Feb 22, 2021
Merged

fix: Fix yamux close #309

merged 5 commits into from
Feb 22, 2021

Conversation

driftluo
Copy link
Collaborator

@driftluo driftluo commented Feb 18, 2021

  1. fix remote does not respond go away

In the current implementation, if the other party does not respond to go away, yamux will wait forever, causing a possible fd attack. Although this is a poorly maintained attack method, during the attack, it must respond to ping/pong messages, otherwise, it will be closed. We cannot be sure whether the remote implementation is fully compliant with the specification. At this time, there must be a shutdown strategy, which is to set a timeout time. When the remote timeout does not respond, the connection will be closed by itself.

Since yamux needs to be runtime independent, the only thing that can be done here is to instantly replace the ping timer, whether it exists or not, at the same time, due to the inconsistency of timer implementation, it is necessary to force the poll once and register it to the corresponding driver, otherwise, it may cause the problem of not being able to wake up(like this ci error)

  1. fix drop with local close should send event

For stream closing, the normal closing process is:

local -- fin ---> remote
remote -- fin ---> local, and remove resources registered in the session
local informs to clean up resources after receiving fin

This is a closing process of a streaming connection with a semi-closed feature

The local close state only performed the fin operation sent to the remote and did not perform notification cleanup

@doitian
Copy link
Member

doitian commented Feb 19, 2021

Could you provide more context about the related design, how to reproduce the problem and how it is fixed? It's really hard for reviewers to catch up this fixing without understanding the whole design of yamux.

Copy link
Member

@doitian doitian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to add more detailed comments to explain how to close the session when the remote peer does not respond to our sent go away code.

yamux/src/stream.rs Show resolved Hide resolved
yamux/src/session.rs Show resolved Hide resolved
yamux/src/session.rs Outdated Show resolved Hide resolved
yamux/src/session.rs Outdated Show resolved Hide resolved
@driftluo driftluo merged commit 9dec36b into master Feb 22, 2021
@driftluo driftluo deleted the fix-yamux-close branch February 22, 2021 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants